package com.gin.no_gay_alliance.utils;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

/**
 * 反射工具类
 *
 * @author : ginstone
 * @version : v1.0.0
 * @since : 2023/9/10 17:05
 **/
public class ReflectUtils {
    /**
     * 递归查找泛型类型
     *
     * @param clazz 类对象
     * @return 泛型类型
     */
    public static ParameterizedType findParameterizedType(Class<?> clazz) {
        Type superclass = clazz.getGenericSuperclass();
        if (superclass instanceof ParameterizedType) {
            return (ParameterizedType) superclass;
        } else if (superclass instanceof Class<?>) {
            return findParameterizedType((Class<?>) superclass);
        }
        System.err.println("superclass = " + superclass);
        return null;
    }
}
